import React from 'react'
import {Navigate} from "react-router-dom"

/**
 * 路由守卫组件
 * @returns 
 */
const getToken = () => {
    return localStorage.token
}
export default function RouterAuth({children}) {
    const token = getToken()
    //验证token，格式 
    if(token){
        return <>{children}</>
    }else{
        return <Navigate to="/"></Navigate>
    }
}
